package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;
    @Override
    public void add(StudentBean student) {
        mapper.insert(student);
    }

    @Override
    public void del(Integer id) {
        mapper.deleteById(id);
    }

    @Override
    public void update(Integer id, String edu) {
        StudentBean student = mapper.selectById(id);
        student.setEdu(edu);
        mapper.updateById(student);
    }

    @Override
    public StudentBean findById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public IPage<StudentBean> cutAll(Integer pageNO) {
        return mapper.selectPage(new Page<>(pageNO,3),null);
    }
}
